package com.cdh.oa.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 菜单表 菜单表
 * </p>
 *
 * @author CDHong
 * @since 2018-11-22
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_menu")
@NoArgsConstructor
public class Menu implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 名称
     */
    @TableField("title")
    private String title;

    /**
     * 图标
     */
    @TableField("icon")
    private String icon;

    /**
     * 是否展开
     */
    @TableField("spread")
    private Boolean spread;

    /**
     * 地址
     */
    @TableField("href")
    private String href;

    /**
     * 上级菜单编号
     */
    @TableField("parent_id")
    private Integer parentId;

    /**
     * 操作人编号
     */
    @JsonIgnore
    @TableField("create_id")
    private Integer createId;

    /**
     * 创建时间
     */
    @JsonIgnore
    @TableField("create_time")
    private LocalDateTime createTime;

    @TableField(exist = false) //映射忽略
    private List<Menu> children;


    public Menu(String title, String icon, Boolean spread, String href, Integer parentId) {
        this.title = title;
        this.icon = icon;
        this.spread = spread;
        this.href = href;
        this.parentId = parentId;
    }
}
